

import 'package:huajianshe_app/network/response/BaseResp.dart';
import 'package:huajianshe_app/pages/circle/model/CircleModel.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:rongcloud_im_plugin/rongcloud_im_plugin.dart';

part 'UserModel.g.dart';

@JsonSerializable()
class UserInfo {

  @JsonKey(name: 'member_sn')
  String? memberSn;

  @JsonKey(name: 'final_name')
  String? nickname; // 如果设置过备注，则这里就是备注，否则就是nickname

  @JsonKey(name: 'final_head')
  String? avatar;

  @JsonKey(name: 'head_pic_id')
  int? avatarId;

  @JsonKey(name: 'company_name')
  String? companyName;

  @JsonKey(name: 'position_name')
  String? positionName;

  @JsonKey(name: 'is_circle_master')
  int? isCaptain;

  @JsonKey(name: 'member_circle_list')
  List<CircleInfo>? circles;

  @JsonKey(name: 'is_friend')
  int? isFriend;

  @JsonKey(name: 'is_self')
  int? isSelf;

  String? realname;//铁昵称，无视备注的存在

  @JsonKey(name: 'wechat_no')
  String? wechatNo; //微信号

  @JsonKey(name: 'has_exchange_mobile') // 是否交换过手机号
  int? hasExchangeMobile;

  @JsonKey(name: 'has_exchange_wechat') // 是否交换过微信
  int? hasExchangeWechat;

  String? email;

  int? sex;

  String? mobile;

  @JsonKey(name: 'self_desc')
  String? desc;

  @JsonKey(name: 'hx_username')
  String? hxId;

  @JsonKey(name: 'hx_password')
  String? hxPwd;

  UserInfo();

  factory UserInfo.fromJson(Map<String, dynamic> json) => _$UserInfoFromJson(json);

  Map<String, dynamic> toJson() => _$UserInfoToJson(this);
}

@JsonSerializable()
class UserHomeResp extends BaseResp {

  UserHomeData? data;

  UserHomeResp();

  factory UserHomeResp.fromJson(Map<String, dynamic> json) => _$UserHomeRespFromJson(json);

  @override
  UserHomeResp parseFromMap(Map<String, dynamic> map) {
    return UserHomeResp.fromJson(map);
  }

}

@JsonSerializable()
class UserHomeData {

  @JsonKey(name: 'member_info')
  UserInfo? userInfo;

  @JsonKey(name: 'circle_list')
  List<CircleInfo>? circles;  //共同的圈子

  @JsonKey(name: 'blog_list')
  List<UserLatestPost>? latestPosts; //最近动态

  @JsonKey(name: 'other_watch_list')
  List<WatchList>? watchList;//推荐列表

  UserHomeData();

  factory UserHomeData.fromJson(Map<String, dynamic> json) => _$UserHomeDataFromJson(json);

}

@JsonSerializable()
class UserLatestPost {

  @JsonKey(name: 'cover_url')
  String? url;

  @JsonKey(name: 'is_video')
  int? isVideo;

  UserLatestPost();

  factory UserLatestPost.fromJson(Map<String, dynamic> json) => _$UserLatestPostFromJson(json);
}

// @JsonSerializable()
// class RecommendationList {
//
//   @JsonKey(name: 'other_watch_list')
//   List<WatchList>? watchList;
//
//   RecommendationList();
//
//   factory RecommendationList.fromJson(Map<String, dynamic> json) => _$RecommendationListFromJson(json);
// }

@JsonSerializable()
class WatchList {

  @JsonKey(name: 'member_info_box')
  UserInfo? userInfo;

  @JsonKey(name: 'member_circle_list')
  List<CircleInfo>? circles;

  WatchList();

  factory WatchList.fromJson(Map<String, dynamic> json) => _$WatchListFromJson(json);

}

@JsonSerializable()
class FriendsResp extends BaseResp {
  List<FriendsData>? data;

  FriendsResp();

  factory FriendsResp.fromJson(Map<String, dynamic> json) => _$FriendsRespFromJson(json);

  @override
  FriendsResp parseFromMap(Map<String, dynamic> map) {
    return FriendsResp.fromJson(map);
  }
}

@JsonSerializable()
class FriendsData {
  String? initial;
  List<FriendInfo>? data;

  FriendsData();
  factory FriendsData.fromJson(Map<String, dynamic> json) => _$FriendsDataFromJson(json);
}

@JsonSerializable()
class FriendInfo {
  @JsonKey(name: 'member_info_box')
  UserInfo? userInfo;
  @JsonKey(ignore: true)
  bool? checked;

  @JsonKey(ignore: true)
  bool? showRadio;
  FriendInfo();
  factory FriendInfo.fromJson(Map<String, dynamic> json) => _$FriendInfoFromJson(json);
}

@JsonSerializable()
class Friend {
  @JsonKey(name: 'circle_id')
  int? circleId;

  String? mobile;

  String? name;

  @JsonKey(name: 'wechat_no')
  String? wechatNo;

  @JsonKey(name: 'company_name')
  String? companyName;

  @JsonKey(name: 'position_name')
  String? positionName;

  @JsonKey(name: 'head_pic_id')
  int? avatar;

  Friend();

  Map<String, dynamic> toJson() => _$FriendToJson(this);
}

@JsonSerializable()
class HxCreateAccountResp extends BaseResp {
  HxCreateAccountData? data;

  HxCreateAccountResp();

  factory HxCreateAccountResp.fromJson(Map<String, dynamic> json) => _$HxCreateAccountRespFromJson(json);

  @override
  HxCreateAccountResp parseFromMap(Map<String, dynamic> map) {
    return HxCreateAccountResp.fromJson(map);
  }
}

@JsonSerializable()
class HxCreateAccountData {
  @JsonKey(name: 'login_hx_username')
  String? meHxId;
  @JsonKey(name: 'login_hx_password')
  String? meHxPwd;
  @JsonKey(name: 'other_hx_username')
  String? otherHxId;
  @JsonKey(name: 'hx_group_id')
  String? hxGroupId;

  HxCreateAccountData();

  factory HxCreateAccountData.fromJson(Map<String, dynamic> json) => _$HxCreateAccountDataFromJson(json);

}

@JsonSerializable()
class MineResp extends BaseResp {
  UserInfo? data;

  MineResp();

  factory MineResp.fromJson(Map<String, dynamic> json) => _$MineRespFromJson(json);

  @override
  MineResp parseFromMap(Map<String, dynamic> map) {
    return MineResp.fromJson(map);
  }
}

@JsonSerializable()
class LabelListResp extends BaseResp {
  List<LabelListData>? data;
  LabelListResp();
  factory LabelListResp.fromJson(Map<String, dynamic> json) => _$LabelListRespFromJson(json);

  @override
  LabelListResp parseFromMap(Map<String, dynamic> map) {
    return LabelListResp.fromJson(map);
  }
}

@JsonSerializable()
class LabelListData {
  String? name;
  @JsonKey(name: 'member_number')
  int? num;
  @JsonKey(name: 'member_list')
  List<LabelName>? labels;

  LabelListData();
  factory LabelListData.fromJson(Map<String, dynamic> json) => _$LabelListDataFromJson(json);
}

@JsonSerializable()
class LabelName {
  @JsonKey(name: 'member_info_box')
  UserInfo? userInfo;
  LabelName();
  factory LabelName.fromJson(Map<String, dynamic> json) => _$LabelNameFromJson(json);
}
